<include file="public@header" />
<style type="text/css">
	input[type="radio"], input[type="checkbox"]{
		margin:12px 3px 12px 20px;
	}
	.table>caption+thead>tr:first-child>th, .table>colgroup+thead>tr:first-child>th, .table>thead:first-child>tr:first-child>th, .table>caption+thead>tr:first-child>td, .table>colgroup+thead>tr:first-child>td, .table>thead:first-child>tr:first-child>td{
		text-align: center;
	}
	.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td{
		text-align: center;
	}
</style>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs" >
			<li class="active" ><a href="javascript:;">统计数据</a></li>
			<if condition="$userinfo['role_id'] eq 6">
				<li ><a href="{:url('stripe/index')}">导入数据</a></li>
				<li ><a  href="{:url('stripe/addhost')}" >添加主机</a></li>
				<li ><a href="{:url('stripe/logs')}" >导入日志</a></li>
			</if>
		</ul>

		<table class="table table-hover table-bordered" style="margin-top: 20px;">
			<if condition="$userinfo['role_id'] eq 7">
				<thead>
					<tr>
						<th>总回款</th>
						<th>总收款</th>
						<th>总payout</th>
						<th>总冻结</th>
						<th>总调整数</th>
						<th>总手续费</th>
						<th>总charge</th>
						<th>总增长</th>
						<th>总回款率</th>
					</tr>
				</thead>

				<tbody id='llltbody2' style="margin-bottom: 40px;">
					<tr>
						<td>{:round($total_statistics['huikuan'],2)}</td>
						<td>{:round($total_statistics['shoukuan'],2)}</td>
						<td>{:round($total_statistics['payout'],2)}</td>
						<td>{:round($total_statistics['dongjie'],2)}</td>
						<td>{:round($total_statistics['tiaozheng'],2)}</td>
						<td>{:round($total_statistics['shouxu'],2)}</td>
						<td>{:round($total_statistics['charge'],2)}</td>
						<td>{:round($total_statistics['zengzhang'],2)}</td>
						<td>{:round($total_statistics['huikuanlv'],2)}</td>
					</tr>
					<tr><td colspan="9"></td></tr>	
				</tbody>
			</if>








			<thead>
				<tr>
					<th>站长</th>
					<th>主机</th>
					<th>收款</th>
					<th>payout</th>
					<th>回款</th>
					<th>冻结</th>
					<th>拒付</th>
					<th>退款</th>
					<th>调整数</th>
					<th>收款天数</th>
					<th>增长</th>
					<th>回款率</th>
					<th>总回款率</th>
					<th>手续费</th>
					<th>charge</th>
				</tr>
			</thead>

			<tbody id='llltbody'>

				<foreach name="arr" item="vo">

					<foreach name="vo['host']" item="vv" key="kk">
				     <tr>
				     	<if condition="$kk eq 0">
				        	<td rowspan="{:count($vo['host'])}"> {$user[$vo['userinfo']['uid']]['user_login'] } </td>  
						</if>

						<td>{$vv}<sup style="color: red">#</sup></td>
						<td>{:round($statistics[$vv]['shoukuan'],2)}</td>
						<td>{:round($statistics[$vv]['payout'],2)}</td>
						<td>
							<a href="javascript:;">
								<span class="glyphicon glyphicon-pencil toopen" aria-hidden="true" style="margin-right: 5px;"  data-toggle="modal" data-host="{$vv}"></span>
							</a>
							{:round($statistics[$vv]['huikuan'],2)}
						</td>
						<td>{:round($statistics[$vv]['dongjie'],2)}</td>
						<td>{:round($statistics[$vv]['jufu'],2)}</td>
						<td>{:round($statistics[$vv]['tuikuan'],2)}</td>
						<td>{:round($statistics[$vv]['tiaozheng'],2)}</td>
						<td>{:round($statistics[$vv]['days'],2)}</td>
						<td>
							<if condition="$statistics[$vv]['zengzhang'] gt 0">
								<font color="green">{:round($statistics[$vv]['zengzhang'],2)}</font>
								<else>
								<font color="red">{:round($statistics[$vv]['zengzhang'],2)}</font>
							</if>
						</td>
						<td>{:round($statistics[$vv]['huikuanlv'],2)}%</td>
						<if condition="$kk eq 0">
							<td  rowspan="{:count($vo['host'])}">{:round($statistics[$vv]['zonghuikuanlv'],2)}%</td>
						</if>
						<td>{:round($statistics[$vv]['shouxu'],2)}</td>
						<td>{:round($statistics[$vv]['charge'],2)}</td>
				     </tr>
			 		</foreach>


				</foreach>
			</tbody>
		</table>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
	  <div class="modal-dialog" role="document">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="exampleModalLabel">录入当前主机的回款金额</h4>
	      </div>
	      <div class="modal-body">
	        <form>
	          <div class="form-group">
	            <label for="recipient-name" class="control-label">回款金额:</label>
	            <input type="number" class="form-control" id="hk" placeholder="汇款金额，格式：数值" style="margin-top: 20px;">
	          </div>

	        </form>
	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-primary tj" id="tj" data-hs="">提交</button>
	      </div>
	    </div>
	  </div>
	</div>

	<script type="text/javascript">

		$('.toopen').click(function(){
			$('#exampleModal').modal('show');
		    $('#hk').val('')
		    $('#tj').data('hs', $(this).data('host'))
		});

		$('#exampleModal').on('hide.bs.modal', function () {
		   window.location.reload();
		})

		$('.tj').click(function(){
			var hk = $('#hk').val();
			var hs = $(this).data('hs');

			if(hk>0 && hs ){
				$('#hk').css('border', '1px solid #ccc');
				$.post('', {hk:hk ,host:hs }, function(rs){
					$('#exampleModal').modal('hide');
					window.location.reload();
				}, 'json')
			}else{
				$('#hk').css('border', '1px solid red');
			}
		});


	</script>

</body>
</html>
